var dazhongDatas = [
    {"brand":"大众","id":"1182379","title":"大众迈腾 1.8T 嘉实多小保养套餐","oprice":"520","price":"469","img_src":"image/jsd-jh-5W-40.jpg"},
    {"brand":"大众","id":"1182380","title":"大众迈腾 2.0T 嘉实多小保养套餐","oprice":"520","price":"469","img_src":"image/jsd-jh-5W-40.jpg"},
    {"brand":"大众","id":"1182381","title":"大众途观 1.8T 嘉实多小保养套餐","oprice":"520","price":"469","img_src":"image/jsd-jh-5W-40.jpg"},
    {"brand":"大众","id":"1182382","title":"大众途观 2.0T 嘉实多小保养套餐","oprice":"520","price":"469","img_src":"image/jsd-jh-5W-40.jpg"},
    {"brand":"大众","id":"1182383","title":"大众朗逸 1.6L 嘉实多小保养套餐","oprice":"240","price":"219","img_src":"image/jsd-jjh-10W-40.jpg"},
    {"brand":"大众","id":"1182384","title":"大众捷达  嘉实多小保养套餐","oprice":"220","price":"199","img_src":"image/jsd-jjh-10W-40.jpg"}
    ]

var aodiDatas = [
    {"brand":"奥迪","id":"1182385","title":"一汽奥迪 A4L 1.8T 嘉实多小保养套餐","oprice":"520","price":"469","img_src":"image/jsd-jh-5W-40.jpg"},
    {"brand":"奥迪","id":"1182386","title":"一汽奥迪 A6L 2.0T 嘉实多小保养套餐","oprice":"520","price":"469","img_src":"image/jsd-jh-5W-40.jpg"},
    {"brand":"奥迪","id":"1182387","title":"一汽奥迪 A6L 2.4L 嘉实多小保养套餐","oprice":"680","price":"599","img_src":"image/jsd-jh-5W-40.jpg"},
    {"brand":"奥迪","id":"1182388","title":"一汽奥迪 Q5 2.0T 嘉实多小保养套餐","oprice":"520","price":"489","img_src":"image/jsd-jh-5W-40.jpg"}
    ]

var richanDatas = [
    {"brand":"日产","id":"1182389","title":"东风日产 骐达 1.6L 嘉实多小保养套餐","oprice":"218","price":"199","img_src":"image/jsd-jjh-10W-40.jpg"},
    {"brand":"日产","id":"1182393","title":"东风日产 颐达  嘉实多小保养套餐","oprice":"218","price":"199","img_src":"image/jsd-yjh-10W-40.jpg"},
    {"brand":"日产","id":"1182390","title":"东风日产 轩逸  嘉实多小保养套餐","oprice":"218","price":"199","img_src":"image/jsd-jjh-10W-40.jpg"},
    {"brand":"日产","id":"1182391","title":"东风日产 天籁 2.0L 嘉实多小保养套餐","oprice":"366","price":"329","img_src":"image/jsd-ch-5W-40.jpg"},
    {"brand":"日产","id":"1182392","title":"东风日产 天籁 2.5L 嘉实多小保养套餐","oprice":"498","price":"449","img_src":"image/jsd-jh-5W-30.jpg"}
    ]

// 2.实例Vue对象
new Vue({
    el: '.g-box',
    data: {
        dazhongData: dazhongDatas,
        aodiData: aodiDatas,
        richanData: richanDatas,
    },
    methods: {
        // APP端接口
        getApp: function(key, value) {
            var appData = { "key": key, "value": value };
            // alert("key值是:"+key+",vlaue值是:"+value);
            //判断访问终端
            var browser = {
                versions: function() {
                    var u = navigator.userAgent,
                        app = navigator.appVersion;
                    return {
                        trident: u.indexOf('Trident') > -1, //IE内核
                        presto: u.indexOf('Presto') > -1, //opera内核
                        webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
                        gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
                        mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
                        ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
                        android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
                        iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
                        iPad: u.indexOf('iPad') > -1, //是否iPad
                        webApp: u.indexOf('Safari') == -1, //是否web应该程序，没有头部与底部
                        weixin: u.indexOf('MicroMessenger') > -1, //是否微信 （2015-01-22新增）
                        qq: u.match(/\sQQ/i) == " qq" //是否QQ
                    };
                }(),
                language: (navigator.browserLanguage || navigator.language).toLowerCase()
            }

            // 判断是安卓还是苹果
            if (browser.versions.android) {
                getAppData(JSON.stringify(appData));
            } else {
                var iver = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
                iver = parseInt(iver[1], 10);
                // IOS 8以上用webkit方法,IOS 8以下用UIWebview方法
                if (iver >= 8) {
                    // AppModel是OC所注入的对象
                    window.webkit.messageHandlers.AppModel.postMessage({ body: appData });
                } else {
                    getAppData(appData);
                }
            }
        }
    }
})